﻿using ICMS.PluginInterfaces;
using commonImportPlugin.FilesCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using commonImportPlugin.Config;
using commonImportPlugin.Common;
using commonImportPlugin.FilesCore.SsseFile;
using commonImportPlugin.Configs.SsseFile;

namespace commonImportPlugin.Factorys
{
    //
    //  抽象工厂
    //
    #region
    /// <summary>
    /// 社保抽象工厂
    /// </summary>
    public abstract class AbstractSsseFile
    {
        public abstract SsseFileCore CreateSsseFileCore();
    }
    /// <summary>
    /// 社保文件处理工厂类
    /// </summary>
    public abstract class SsseFileCore
    {
        /// <summary>
        /// 获取所有社保数据
        /// </summary>
        public abstract List<ICData> GetSsseAllDatas(string ssseFilePath, out int ssseCounts);
        /// <summary>
        /// 检查社保数据
        /// </summary>
        public abstract bool CheckSsseData(string ssseFilePath, string regexstr);
        /// <summary>
        /// 获取所有社保数据量
        /// </summary>
        public abstract int GetSsseAllCounts(string ssseFilePath);

    }
    #endregion

    //
    //  工厂集
    //
    #region
    public class SsseFileCoreFactory : AbstractSsseFile
    {
        public override SsseFileCore CreateSsseFileCore()
        {
            SsseFileCoreClass core = new SsseFileCoreClass();
            return core.GetInstance();
        }
    }
    public class SsseFileCoreExcelFactory : AbstractSsseFile
    {
        public override SsseFileCore CreateSsseFileCore()
        {
            SsseFileCoreExcelClass core = new SsseFileCoreExcelClass();
            return core.GetInstance() ;
        }
    }
    #endregion


    //
    //  简单工厂
    //
    #region
    /// <summary>
    /// 社保简单工厂
    /// </summary>
    public class setSsseFileCoreFactory
    {
        public SsseFileCore CreateFactory(string whichFactory)
        {
            switch (whichFactory)
            {
                case "General":
                    //初始化配置
                    SsseFileConfig ssseFileConfig = new SsseFileConfig();
                    ssseFileConfig.Init();
                    //返回初始化核心
                    return new SsseFileCoreFactory().CreateSsseFileCore();
                case "Excel":
                    //初始化配置
                    SsseFileConfigExcel ssseFileConfigExcel = new SsseFileConfigExcel();
                    ssseFileConfigExcel.Init();
                    //返回初始化核心
                    return new SsseFileCoreExcelFactory().CreateSsseFileCore();
                default:
                    break;
            }
            return null;
        }
    }
    #endregion
}
